﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}

<section class="content-header">
    <h1>
        网办订单
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active">网办订单</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <div class="form-inline">
                        <div class="form-group">
                            <label>订单编码</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="10" id="txtOrderCode" autocomplete="off" />
                        </div>
                        <div data-toggle="distpicker" class="form-group">
                            <label>所在地</label>
                            <select name="ProvinceID" id="ProvinceID" class="form-control"></select>
                            <select name="CityID" id="CityID" class="form-control"></select>
                        </div>
                        <div class="form-group">
                            <label>分类</label>
                            <select class="form-control" style="width:150px;" name="selMasterBizType" id="selMasterBizType"></select>
                            <select class="form-control" style="width:150px;" name="selBizType" id="selBizType"></select>
                        </div>
                        <div class="form-group">
                            <label>创建时间</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="20" id="txtStartDate" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" style="width:100px;" name="txtEndDate" maxlength="20" id="txtEndDate" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnSearch">查找</button>
                        </div>

                        <h3 class="box-title"></h3>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover body-table-head">
                        <thead>
                            <tr>
                                <th>
                                    订单编码
                                </th>
                                <th>
                                    办理城市
                                </th>
                                <th>
                                    业务类型
                                </th>
                                <th>
                                    姓名
                                </th>
                                <th>
                                    手机号
                                </th>
                                <th>
                                    车牌号
                                </th>
                                <th>
                                    订单状态
                                </th>
                                <th>
                                    支付状态
                                </th>
                                <th>
                                    创建时间
                                </th>
                                <th class="t_c">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody id="tbodylist"></tbody>
                    </table>
                    <div class="no-data" id="nodata" style="display:none;">
                        <div class="img-box"></div>
                        <div class="text">暂无数据</div>
                    </div>
                </div>
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
                <!-- /.box-body -->
                <!-- /.box -->
            </div>
        </div>
    </div>
</section>

@section scriptsBottom{
    <script src="@Url.Content("~/lib/art-template/template-web.js")"></script>
    <script id="dataItemTpl" type="text/html">
        {{each data}}
        <tr>
            <td class="title">
                {{$value.OrderID}}
            </td>
            <td class="title">
                {{$value.ProvinceName}}-{{$value.CityName}}
            </td>
            <td>
                {{$value.BizTypeName}}
            </td>
            <td>
                {{$value.UserName}}
            </td>
            <td>
                {{$value.UserMobile}}
            </td>
            <td>
                {{$value.PlateNo}}
            </td>
            <td>
                <a href="#" onclick="auditInfo('{{$value.OrderID}}')"> {{$value.OrderStatusName}}</a>
            </td>
            <td>
                {{$value.PayStatusName}}
            </td>
            <td>
                {{$value.CreatedDate}}
            </td>
            <td class="t_c">
                <button type="button" class="btn btn-info btn-xs" onclick="info('{{$value.OrderID}}')">详情</button>
                @*<button type="button" class="btn btn-warning btn-xs" onclick="audit('{{$value.OrderID}}')">审核</button>*@
                
            </td>
        </tr>
        {{/each}}
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#txtStartDate").datepicker({
                language: "zh-CN",
                autoclose: true,//选中之后自动隐藏日期选择框
                format: "yyyy-mm-dd"//日期格式，
            });
            $("#txtEndDate").datepicker({
                language: "zh-CN",
                autoclose: true,//选中之后自动隐藏日期选择框
                format: "yyyy-mm-dd"//日期格式，
            });

            $("#btnSearch").click(function () {
                pageIndex = 1;
                search();
            });

            //分类
            initMasterBizType();
            initBindBizType();
            search();
            $("#btnAdd").click(function () {
                edit('添加办事指南');
            });
        });

        //页码
        var pageIndex = 1;
        //查询
        function search() {
            var url = '@Url.Action("GetOrderList", "Order")'
            //查询列表
            BMCW.ajax({
                url: url,
                type: 'GET',
                dataType: "json",
                data: {
                    provinceid: $("#ProvinceID").val(),
                    cityid: $("#CityID").val(),
                    masterbiztype:$("#selMasterBizType").val(),
                    biztype: $("#selBizType").val(),
                    sDate: $("#txtStartDate").val(),
                    eDate: $("#txtEndDate").val(),
                    orderid:$("#txtOrderCode").val(),
                    rows: 10,
                    page: pageIndex
                },
                success: function (data) {
                    if (data.data.length < 1) {
                        $("#nodata").show();
                        document.getElementById('tbodylist').innerHTML = "";
                        return;
                    }
                    $("#nodata").hide();
                    //模板渲染
                    var data = data;
                    var html = template('dataItemTpl', data);
                    document.getElementById('tbodylist').innerHTML = html;
                    //分页显示
                    $('#pagination').twbsPagination("destroy");
                    $('#pagination').twbsPagination({
                        totalItems: parseInt(data.message),
                        visiblePages: 10,
                        pageSize: 10,
                        startPage: parseInt(pageIndex),
                        onPageClick: function (event, page) {
                            pageIndex = page;
                            search();
                        }
                    });
                }
            });
        }

        //一级分类
        function initMasterBizType()
        {
            var url = '@Url.Action("GetMasterBizTypeList", "BasicData")';
            $("#selMasterBizType").append("<option value='0'>全部分类</option>");
            BMCW.ajax({
                url: url,
                type: "GET",
                success: function (o) {
                    if (o.status == 0) {
                        $.each(o.data, function (i) {
                            $("#selMasterBizType").append("<option value='" + o.data[i].MasterBizTypeID + "'>" + o.data[i].MasterBizTypeName + "</option>");
                        });
                    }
                }
            });
        }

        function initBindBizType()
        {
            var url = '@Url.Action("GetBizTypeListByMasterId", "BasicData")';
            $("#selBizType").append("<option value=''>全部子类</option>");
            $("#selMasterBizType").bind("change", function () {
                var typeId = $(this).val();
                BMCW.ajax({
                    url: url,
                    data:{ "masterId": typeId },
                    type:"GET",
                    success: function (rd) {
                        if (rd.status == 0) {
                            $("#selBizType").empty();
                            $("#selBizType").append("<option value=''>全部子类</option>");
                            var dataObj = rd.data;
                            for (var i = 0; i < dataObj.length; i++) {
                                var bizTypeId = dataObj[i].BizTypeID;
                                var bizTypeName = dataObj[i].BizTypeName;
                                $("#selBizType").append("<option value='" + bizTypeId + "'>" + bizTypeName + "</option>");
                            }
                        }
                    }
                })
            });
        }

        function info(id)
        {
            location.href = "OrderInfo?orderId=" + id;
        }

        function audit(id)
        {
            var url = '@Url.Action("OrderAudit", "Order")';
            BMCW.showTopLayer("订单审核", url + "?orderId="+id, 630, 438);
        }

        function auditInfo(id) {
            var url = '@Url.Action("OrderAuditResult", "Order")';
            BMCW.showTopLayer("订单审核信息", url + "?orderId=" + id, 630, 438);
        }
    </script>
}

